# WineStarter Profile
PROFILE="$HOME/.WineStarter"

[ ! -e "${PROFILE}" ] && cat <<EOF > "${PROFILE}"
DEFAULT_APP="explorer"
VD_NAME=""
VD_SIZE=""
WINEPREFIX=""
WINEDEBUG="-all"
#XTERM="/opt/X11/bin/xterm"
EOF

. "${PROFILE}"

[ "${WINEPREFIX}" ] && export WINEPREFIX
[ "${WINEDEBUG}" -a ! "${XTERM}" ] && export WINEDEBUG
[ "${VD_SIZE}" ] && VD="explorer /desktop=${VD_NAME},${VD_SIZE}"

# For Homebrew Users
[ -x "/usr/local/bin/wine" ] && PATH="/usr/local/bin:${PATH}"

# For MacPorts Users
[ -x "/opt/local/bin/wine" ] && PATH="/opt/local/bin:${PATH}"

export PATH

APP="${@:-${DEFAULT_APP}}"

[ $(echo "${APP}" | egrep -i "\.msi$") ] && MSIEXEC="msiexec /i"

START_WINE="eval wine ${VD} ${MSIEXEC} \"${APP}\""

if [ -x "${XTERM}" ] ; then

	${XTERM} -geometry +0+0 -e bash -c "${START_WINE}" &

else

	${START_WINE} &

fi
